﻿using CP.Utility;
using GPM;
using LF3.Controllers;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LF3Proj
{
    public partial class FrmSampleCount : Form
    {
        public FrmSampleCount()
        {
            InitializeComponent();
        }

        private string HeatID;
        public FrmSampleCount(string heatid)
            : this()
        {
            this.HeatID = heatid;
        }

        private void FrmSampleCount_Load(object sender, EventArgs e)
        {
            this.txtSampleHeatId.Text = this.HeatID;
            GetSampleCount();
        }

        private void GetSampleCount()
        {
            LF_CurrentHeatController ctl = new LF_CurrentHeatController();
            int count = ctl.GetHeatSampleCount(this.HeatID);
            spinCount.EditValue = count + 1;
        }

        private void btnSampleEvent_Click(object sender, EventArgs e)
        {
            try
            {
                LF_CurrentHeatController ctl = new LF_CurrentHeatController();
                ctl.AddSampleEvent(this.HeatID, Convert.ToInt32(this.spinCount.EditValue));
                
                ExMessageBox.Show("提示信息：新增取样事件成功！", AppSetter.SoftName);
                LogHelper.Log("炉次取样画面", "新增", "新增取样事件", this.HeatID, this.spinCount.EditValue.ToString());
                this.Close();
            }
            catch (Exception ex)
            {
                ExMessageBox.Show("提示信息：" + ex.Message, AppSetter.SoftName);
            }
        }
    }
}
